﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:MahApps.Metro.Controls">


    <ControlTemplate x:Key="RangeSliderHorizontal"
                     TargetType="controls:RangeSlider">
        <StackPanel Name="PART_Container"
                    Orientation="Vertical"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center">
            <TickBar Name="PART_TopTick"
                     Placement="Top"
                     Fill="{TemplateBinding Foreground}"
                     TickFrequency="{TemplateBinding TickFrequency}"
                     Minimum="{TemplateBinding Minimum}"
                     Maximum="{TemplateBinding Maximum}"
                     Height="4"
                     Margin="5,0,5,2"
                     Visibility="Collapsed"></TickBar>
            <StackPanel Name="PART_RangeSliderContainer"
                        Background="Transparent"
                        Orientation="Horizontal"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Center">
                <RepeatButton Name="PART_LeftEdge"
                              Style="{DynamicResource HorizontalTrackLargeDecrease}" />
                <Thumb Name="PART_LeftThumb"
                       Cursor="Arrow"
                       Height="{DynamicResource HorizontalThumbHeight}"
                       Width="{DynamicResource HorizontalThumbWidth}"
                       Style="{DynamicResource HorizontalSliderThumb}" />
                <Thumb Name="PART_MiddleThumb"
                       Cursor="Hand"
                       MinWidth="{TemplateBinding MinRangeWidth}">
                    <Thumb.Style>
                        <Style TargetType="Thumb">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <Rectangle Height="5"
                                                   Margin="0,1,0,0"
                                                   Fill="{DynamicResource AccentColorBrush}" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Thumb.Style>
                </Thumb>
                <Thumb Name="PART_RightThumb"
                       Cursor="Arrow"
                       Height="{DynamicResource HorizontalThumbHeight}"
                       Width="{DynamicResource HorizontalThumbWidth}"
                       Style="{DynamicResource HorizontalSliderThumb}" />
                <RepeatButton Name="PART_RightEdge"
                              Style="{DynamicResource HorizontalTrackLargeDecrease}" />
            </StackPanel>
            <TickBar Name="PART_BottomTick"
                     Fill="{TemplateBinding Foreground}"
                     Placement="Top"
                     TickFrequency="{TemplateBinding TickFrequency}"
                     Minimum="{TemplateBinding Minimum}"
                     Maximum="{TemplateBinding Maximum}"
                     Height="4"
                     Margin="5,2,5,0"
                     Visibility="Collapsed"></TickBar>
        </StackPanel>
        <ControlTemplate.Triggers>
            <Trigger Property="TickPlacement"
                     Value="TopLeft">
                <Setter Property="Visibility"
                        TargetName="PART_TopTick"
                        Value="Visible" />
            </Trigger>
            <Trigger Property="TickPlacement"
                     Value="BottomRight">
                <Setter Property="Visibility"
                        TargetName="PART_BottomTick"
                        Value="Visible" />
            </Trigger>
            <Trigger Property="TickPlacement"
                     Value="Both">
                <Setter Property="Visibility"
                        TargetName="PART_TopTick"
                        Value="Visible" />
                <Setter Property="Visibility"
                        TargetName="PART_BottomTick"
                        Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="RangeSliderVertical"
                     TargetType="controls:RangeSlider">
        <StackPanel Name="PART_Container"
                    Orientation="Horizontal"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Stretch">
            <TickBar Name="PART_TopTick"
                     Placement="Left"
                     Fill="{TemplateBinding Foreground}"
                     TickFrequency="{TemplateBinding TickFrequency}"
                     Minimum="{TemplateBinding Minimum}"
                     Maximum="{TemplateBinding Maximum}"
                     Width="4"
                     Margin="0,5,2,5"
                     Visibility="Collapsed"></TickBar>
            <StackPanel Orientation="Vertical"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Stretch"
                        Background="Transparent"
                        Name="PART_RangeSliderContainer">
                <RepeatButton Name="PART_RightEdge"
                              VerticalAlignment="Stretch"
                              Style="{DynamicResource VerticalTrackLargeDecrease}" />
                <Thumb Name="PART_RightThumb"
                       Cursor="Arrow"
                       Height="{DynamicResource VerticalThumbHeight}"
                       Width="{DynamicResource VerticalThumbWidth}"
                       Style="{DynamicResource VerticalSliderThumb}" />

                <Thumb Name="PART_MiddleThumb"
                       Cursor="Hand"
                       MinHeight="{TemplateBinding MinRangeWidth}">
                    <Thumb.Style>
                        <Style TargetType="Thumb">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <Rectangle Width="5"
                                                   Margin="0,0,0,0"
                                                   Fill="{DynamicResource AccentColorBrush}" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </Thumb.Style>
                </Thumb>

                <Thumb Name="PART_LeftThumb"
                       Cursor="Arrow"
                       Height="{DynamicResource VerticalThumbHeight}"
                       Width="{DynamicResource VerticalThumbWidth}"
                       Style="{DynamicResource VerticalSliderThumb}" />
                <RepeatButton Name="PART_LeftEdge"
                              VerticalAlignment="Stretch"
                              Style="{DynamicResource VerticalTrackLargeDecrease}" />
            </StackPanel>
            <TickBar Name="PART_BottomTick"
                     Fill="{TemplateBinding Foreground}"
                     TickFrequency="{TemplateBinding TickFrequency}"
                     Minimum="{TemplateBinding Minimum}"
                     Maximum="{TemplateBinding Maximum}"
                     Placement="Right"
                     Width="4"
                     Margin="2,5,0,5"
                     Visibility="Collapsed"></TickBar>
        </StackPanel>
        <ControlTemplate.Triggers>
            <Trigger Property="TickPlacement"
                     Value="TopLeft">
                <Setter Property="Visibility"
                        TargetName="PART_TopTick"
                        Value="Visible" />
            </Trigger>
            <Trigger Property="TickPlacement"
                     Value="BottomRight">
                <Setter Property="Visibility"
                        TargetName="PART_BottomTick"
                        Value="Visible" />
            </Trigger>
            <Trigger Property="TickPlacement"
                     Value="Both">
                <Setter Property="Visibility"
                        TargetName="PART_TopTick"
                        Value="Visible" />
                <Setter Property="Visibility"
                        TargetName="PART_BottomTick"
                        Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type controls:RangeSlider}">
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="Template"
                Value="{StaticResource RangeSliderHorizontal}" />
        <Style.Triggers>
            <Trigger Property="Orientation"
                     Value="Vertical">
                <Setter Property="Template"
                        Value="{StaticResource RangeSliderVertical}" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>